<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<%@include file="../../commons/meta.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<c:set var="baseUrl" value="${ctx}api/characterTopic/" scope="request" />
<c:set var="dicUrl" value="${ctx}api/dic/" scope="request" />
<c:set var="characterClassUrl" value="${ctx}api/restCharacterClass/"
	scope="request" />
<link rel="stylesheet" href="${ctx}assets/plugins/pure/pure-min.css"
	media="all" />
<script type="text/javascript"
	src="${ctx}assets/plugins/plupload/2.2.1/js/plupload.full.min.js"></script>
<script type="text/javascript"
	src="${ctx}assets/plugins/plupload/2.2.1/js/i18n/zh_CN.js"></script>

<script type="text/javascript">

function defaultOption(){
	$("#characterClass").empty();
	$.ajax({
		url:"${characterClassUrl}byssll?sslx=mbti_zyxgcp",  
        type:"get",
        contentType:"application/json",
        dataType:"json",
        error:function(msg){
        	//alert("error:" + JSON.stringify(msg));
        },
		success:function(data){
			//alert("success"+ JSON.stringify(data));
            if(data!=null && data.length != 0){
			    var option =  "<option value='99'>请选择</option>";
                for(var i=0; i< data.length; i++){
                	if(${obj.mOpitons[0].lx} == data[i].id) {
            			option=option+"<option value='"+data[i].id+'#' +data[i].name+"' selected='selected'>"+data[i].name+"</option>";
            		} else {
            			option=option+"<option value='"+data[i].id+'#' +data[i].name+"'>"+data[i].name+"</option>";
            		}
                    //option=option+"<option value='"+dataClass[i].id+"'>"+dataClass[i].name+"</option>";  
                }  
                $("#characterClass").append(option);  
            }
		},
		complete:function(){
			//alert("complete");
		}
	});
};

window.onload = defaultOption();

function validateForm(){
	if (empty($("#topic").val())) {
	      alertError('请输入题目内容！');
	      return false;
	    }
	
	if("99" == $("#characterClass").val()){
		alertError("请选择性格类型");
		return false;
	} else{
		alert($("#characterClass").val());
	}
	$("#forms").submit();
};

function back(){
	window.location.href = "${baseUrl}";
}
</script>


</head>
<body>
	<%@include file="../../commons/head.jsp"%>
	<div class="content">
		<%@include file="../../commons/menu.jsp"%>
		<!--右侧展示部分-->
		<div class="right-zq">
			<!--center content-->
			<div class="dynamic">
				<form class="" id="forms" method="post" action="${baseUrl}update">
				<div class="role dynamiclayer" style="display: block;">
						<div class="title orange2">
							<span class="left">专业评测管理</span> <label> > </label> <span>评测试题编辑</span>
						</div>
					<div class="news-table">
						<table>
							<tr>
								<td class="item">题目内容:</td>
								<td width="40%"><input class="p100" id="topic" name="topic"
									type="text" placeholder="请输入题目内容" value="${obj.topic}" /></td>
							</tr>
							<tr>
								<td class="item">性格类型:</td>
								<td width="40%"><select id="characterClass"
									name="characterClass" class="p100" style="text-align: left;"></select></td>
							</tr>
							
							<tr>
								<td></td>
								<td>
									<button class="orange2" type="button" onclick="validateForm()">
										保存&nbsp;<i class="fa fa-floppy-o"></i>
									</button> &nbsp;&nbsp;
									<button class="orange2" type="button" id="back_btn" onclick="back()">
										返回&nbsp;<i class="fa fa-undo"></i>
									</button>
								</td>
							</tr>
							<tr>
								<td><input id="fileId" name="id" type="hidden"
									placeholder="" value="${obj.id }" /></td>
							</tr>
						</table>
					</div>
				</div>
				</form>
			</div>
		</div>
	</div>

	<%@include file="../../commons/footpop.jsp"%>
</body>
</html>